package com.skynet.springcloud.consumer.auth.controller;

import com.skynet.springcloud.consumer.auth.dto.UserAuthDTO;
import com.skynet.springcloud.consumer.auth.service.UserAuthService;
import com.skynet.springcloud.consumer.auth.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class UserAuthController {

    @Autowired
    private UserAuthService userAuthService;

    @PostMapping("/login")
    public ResultVO login(@RequestBody UserAuthDTO userAuthDTO){
        return userAuthService.login(userAuthDTO);
    }

    @PostMapping("/register")
    public ResultVO register(@RequestBody UserAuthDTO userAuthDTO){
        return userAuthService.register(userAuthDTO);
    }

    @DeleteMapping("/logout")
    public ResultVO logout(){
        return userAuthService.logout();
    }

    @PostMapping("/request-pass")
    public ResultVO requestPass(@RequestBody UserAuthDTO userAuthDTO){
        return userAuthService.requestPass(userAuthDTO);
    }

    @PutMapping("/reset-pass")
    public ResultVO resetPass(@RequestBody UserAuthDTO userAuthDTO){
        return userAuthService.resetPass(userAuthDTO);
    }
}
